#ifndef ros_robot_QNODE_HPP_
#define ros_robot_QNODE_HPP_

#ifndef Q_MOC_RUN
#include <ros/ros.h>
#include <image_transport/image_transport.h>
#endif

#include <string>
#include <QThread>
#include <QStringListModel>

#include <map>

#include <geometry_msgs/Twist.h>

#include <nav_msgs/Odometry.h>//turtlebot3
#include <turtlesim/Pose.h>//turtlesim

#include <std_msgs/Float32.h>
#include <cv_bridge/cv_bridge.h>
#include <sensor_msgs/image_encodings.h>
#include <QImage>
namespace ros_robot {
    class QNode : public QThread {
    Q_OBJECT

    private:
        int init_argc;
        char** init_argv;

        ros::Publisher cmd_vel_publisher;

        ros::Subscriber odom_sub;//turtlebot3
        void odom_callBack(const nav_msgs::Odometry &msg);//turtlebot3
        //ros::Subscriber pose_sub;//turtlesim
        //void pose_callBack(const turtlesim::Pose& msg);//turtlesim

        ros::Subscriber power_subscriber;
        void power_callBack(const std_msgs::Float32& msg);

        image_transport::Subscriber image_subscriber;
        void image_callBack(const sensor_msgs::ImageConstPtr& msg);
        QImage Mat2QImage(cv::Mat const& src);

    public:
        QNode(int argc, char** argv );
        virtual ~QNode();
        bool init();
        bool init(const std::string &master_url, const std::string &host_url);
        void run();
	
        void set_cmd_vel(char k,double linear,double angular);
        void sub_image(QString topic_name);


    Q_SIGNALS:
        void rosShutdown();

        void speed_vel(float,float);
        void power_vel(float);
        void image_val(QImage);
    };
}

#endif /* ros_robot_QNODE_HPP_ */
